import { handleActions } from "redux-actions";
import { GET_ONE_COMM } from "../types.js";
import _ from "lodash";

// 初始化数据
const InitData = {
    name: "",
    price: 1,
    count: 1,
    desc: "",
    image: [],
    isAttend: false,
    childId: "",
    parentId: "",
    childType:"",
    poster:[]
}


export const comm = handleActions({
    // 获取所有类型
    [GET_ONE_COMM]: (state, { payload }) => {
        const { data, parentId } = payload;
        const { name, count, price, desc, image, childId, isAttend,poster }=data
        return _.assign({}, state, {
            name, count, price, desc, image, childId, isAttend, parentId,poster
        })
    },
}, InitData)